home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / getscr1r / frmwinvi.frm (.txt) < prev    next >
Visual Basic Form  |  1999-09-06  |  16KB  |  424 lines

  1. VERSION 5.00
  2. Begin VB.Form frmWinView 
  3.    AutoRedraw      =   -1  'True
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "Windows Information Viewer - By Chong Long Choo"
  6.    ClientHeight    =   8205
  7.    ClientLeft      =   45
  8.    ClientTop       =   330
  9.    ClientWidth     =   6780
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   547
  14.    ScaleMode       =   3  'Pixel
  15.    ScaleWidth      =   452
  16.    StartUpPosition =   2  'CenterScreen
  17.    Begin VB.ListBox lstOwnedWin 
  18.       ForeColor       =   &H00FF0000&
  19.       Height          =   450
  20.       Left            =   120
  21.       TabIndex        =   13
  22.       TabStop         =   0   'False
  23.       Top             =   2880
  24.       Width           =   6555
  25.    End
  26.    Begin VB.ListBox lstChildWin 
  27.       ForeColor       =   &H00FF0000&
  28.       Height          =   645
  29.       Left            =   120
  30.       TabIndex        =   11
  31.       TabStop         =   0   'False
  32.       Top             =   1800
  33.       Width           =   6555
  34.    End
  35.    Begin VB.CommandButton cmdRefresh 
  36.       Caption         =   "Refresh"
  37.       Height          =   375
  38.       Left            =   120
  39.       TabIndex        =   9
  40.       Top             =   7680
  41.       Width           =   1935
  42.    End
  43.    Begin VB.ListBox lstTopLevelWin 
  44.       ForeColor       =   &H00FF0000&
  45.       Height          =   1035
  46.       Left            =   120
  47.       TabIndex        =   3
  48.       TabStop         =   0   'False
  49.       Top             =   360
  50.       Width           =   6555
  51.    End
  52.    Begin VB.ListBox ListInfo 
  53.       ForeColor       =   &H00FF0000&
  54.       Height          =   840
  55.       Index           =   0
  56.       Left            =   4560
  57.       TabIndex        =   2
  58.       TabStop         =   0   'False
  59.       Top             =   3720
  60.       Width           =   2175
  61.    End
  62.    Begin VB.TextBox Text1 
  63.       Appearance      =   0  'Flat
  64.       ForeColor       =   &H00FF0000&
  65.       Height          =   285
  66.       Index           =   0
  67.       Left            =   1920
  68.       Locked          =   -1  'True
  69.       TabIndex        =   1
  70.       TabStop         =   0   'False
  71.       Top             =   3480
  72.       Visible         =   0   'False
  73.       Width           =   1815
  74.    End
  75.    Begin VB.CommandButton cmdTrack 
  76.       Caption         =   "Start Tracking"
  77.       Height          =   375
  78.       Left            =   2160
  79.       TabIndex        =   0
  80.       Top             =   7680
  81.       Width           =   1935
  82.    End
  83.    Begin VB.Timer Timer1 
  84.       Enabled         =   0   'False
  85.       Interval        =   50
  86.       Left            =   2400
  87.       Top             =   4080
  88.    End
  89.    Begin VB.Label Label4 
  90.       Height          =   255
  91.       Left            =   120
  92.       TabIndex        =   12
  93.       Top             =   2520
  94.       Width           =   5055
  95.       WordWrap        =   -1  'True
  96.    End
  97.    Begin VB.Label Label3 
  98.       Height          =   255
  99.       Left            =   120
  100.       TabIndex        =   10
  101.       Top             =   1440
  102.       Width           =   5055
  103.       WordWrap        =   -1  'True
  104.    End
  105.    Begin VB.Label Label5 
  106.       Caption         =   "CLASS"
  107.       Height          =   255
  108.       Index           =   2
  109.       Left            =   3600
  110.       TabIndex        =   8
  111.       Top             =   120
  112.       Width           =   1215
  113.    End
  114.    Begin VB.Label Label5 
  115.       Caption         =   "BASE"
  116.       Height          =   255
  117.       Index           =   1
  118.       Left            =   1440
  119.       TabIndex        =   7
  120.       Top             =   120
  121.       Width           =   1215
  122.    End
  123.    Begin VB.Label Label5 
  124.       Caption         =   "HWND"
  125.       Height          =   255
  126.       Index           =   0
  127.       Left            =   120
  128.       TabIndex        =   6
  129.       Top             =   120
  130.       Width           =   1215
  131.    End
  132.    Begin VB.Label Label2 
  133.       AutoSize        =   -1  'True
  134.       Caption         =   "Class Info:"
  135.       Height          =   195
  136.       Index           =   0
  137.       Left            =   4560
  138.       TabIndex        =   5
  139.       Top             =   3480
  140.       Visible         =   0   'False
  141.       Width           =   735
  142.    End
  143.    Begin VB.Label Label1 
  144.       AutoSize        =   -1  'True
  145.       Caption         =   "&Hwnd:"
  146.       Height          =   195
  147.       Index           =   0
  148.       Left            =   240
  149.       TabIndex        =   4
  150.       Top             =   3480
  151.       Visible         =   0   'False
  152.       Width           =   465
  153.    End
  154. Attribute VB_Name = "frmWinView"
  155. Attribute VB_GlobalNameSpace = False
  156. Attribute VB_Creatable = False
  157. Attribute VB_PredeclaredId = True
  158. Attribute VB_Exposed = False
  159. Option Explicit
  160. ' Name:     Windows Information Viewer
  161. ' Author:   Chong Long Choo
  162. ' Date:     06 September 1999
  163. Private Type POINTAPI
  164.     x As Long
  165.     y As Long
  166. End Type
  167. Private objWinView As clsWinView
  168. Attribute objWinView.VB_VarHelpID = -1
  169. Private Declare Function SendMessageLongByRef Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, lParam As Long) As Long
  170. Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
  171. Private Declare Function GetDesktopWindow Lib "user32" () As Long
  172. Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
  173. Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
  174. Private Const HWND_TOPMOST = -1
  175. Private Const HWND_NOTOPMOST = -2
  176. Private Const SWP_NOMOVE = &H2
  177. Private Const SWP_NOSIZE = &H1
  178. Private Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
  179. Private Const BITSPIXEL As Long = 12
  180. Private Const HORZRES As Long = 8
  181. Private Const VERTRES As Long = 10
  182. Private Const LB_SETTABSTOPS = &H192
  183. ' Load all label, text box and list box
  184. Private Sub LoadLabelText()
  185.     Dim ArrayCaption1 As Variant
  186.     Dim ArrayCaption2 As Variant
  187.     Dim i As Byte
  188.     ArrayCaption1 = Array("Base:", "Class:", _
  189.         "Position:", "Size (Horizontal):", "Size (Vertical):", _
  190.         "Class Extra:", "Word Extra:", "Control Name:", _
  191.         "Parent Window:", "Window Name:")
  192.     ArrayCaption2 = Array("Condition:", "Style:", "Extra Style:")
  193.     Label2(0).Visible = True
  194.     ListInfo(0).Visible = True
  195.     For i = 1 To 3
  196.         Load Label2(i)
  197.         Load ListInfo(i)
  198.         ListInfo(i).Move 304, ListInfo(i - 1).Top + 80
  199.         Label2(i).Caption = ArrayCaption2(i - 1)
  200.         Label2(i).Move 304, Label2(i - 1).Top + 80
  201.         Label2(i).Visible = True
  202.         ListInfo(i).Visible = True
  203.     Next
  204.     Label1(0).Visible = True
  205.     Text1(0).Visible = True
  206.     For i = 1 To 10
  207.         Load Label1(i)
  208.         Load Text1(i)
  209.         Label1(i).Caption = ArrayCaption1(i - 1)
  210.         Label1(i).Move 16, Label1(i - 1).Top + 24
  211.         Text1(i).Move 128, Text1(i - 1).Top + 24
  212.         Text1(i).Visible = True
  213.         Label1(i).Visible = True
  214.     Next
  215. End Sub
  216. ' Refresh the list of top level windows
  217. Private Sub cmdRefresh_Click()
  218.     LoadTopLevelWindows
  219. End Sub
  220. 'List top level windows
  221. Private Sub LoadTopLevelWindows()
  222.     lstTopLevelWin.Clear
  223.     objWinView.ListTopLevelWindow
  224.     lstTopLevelWin.ListIndex = 0
  225. End Sub
  226. ' Detect the information of the window which under
  227. ' the mouse
  228. Private Sub cmdTrack_Click()
  229.     Static bTracking As Boolean
  230.     If Not bTracking Then
  231.         objWinView.SetPointMode hwnd
  232.         WinInfo objWinView.GetWindowDesc(cmdTrack.hwnd)
  233.         bTracking = True
  234.         cmdTrack.Caption = "Stop Tracking"
  235.         Timer1.Enabled = True
  236.     Else
  237.         objWinView.ResetPointMode hwnd
  238.         cmdTrack.Caption = "Start Tracking"
  239.         bTracking = False
  240.         Timer1.Enabled = False
  241.     End If
  242. End Sub
  243. Private Sub Form_Activate()
  244.     ' set the form to top most
  245.     Call SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
  246. End Sub
  247. 'Detect screen resolution
  248. 'If the current horizontal resolution and the current
  249. 'vertical resolution do not greater than 800 and 600,
  250. 'the sample will be terminated automatically.
  251. Private Sub DetectScreenResolution()
  252.     Dim HRes As Long
  253.     Dim VRes As Long
  254.     HRes = GetDeviceCaps(hdc, HORZRES)
  255.     VRes = GetDeviceCaps(hdc, VERTRES)
  256.     If HRes < 800 A